/**
 * Created by Administrator on 2017/7/20.
 */
/**
 * Created by Administrator on 2017/6/22.
 */
/*获取商铺文件*/
var ye1 = document.getElementsByClassName("ye1");
for (var i = 0; i < ye1.length; i++) {
    ye1[i].onclick = function () {
        var xhr = new XMLHttpRequest();
        xhr.open("get", "http://localhost:3000/dianpu?city=beijing&pageNum="+this.innerHTML, true);
        xhr.send();
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                if (xhr.status >= 200 && xhr.status < 300) {
                    createDiv(JSON.parse(xhr.responseText));
                }
                ;
            }
            ;
        }
    }
}

/*动态创建商铺。点击页面按钮，出现相对应的页面和数据*/
    var store=document.querySelector(".store");
    var good=document.querySelector(".good");
    function createDiv(data) {
        var size = document.createElement("p");
        size.className = "size";
        size.innerHTML = "商家好评榜";
        good.appendChild(size);
        for (var i = 0; i < data.shop_data.length; i++) {
            var div0 = document.createElement("div");
            div0.className = "shop";
            div0.onmouseenter = blockHandler;
            div0.onmouselive = blockHandler;
            store.appendChild(div0);
            var img0 = document.createElement("img");
            img0.src = data.shop_data[i].shop_ico;
            div0.appendChild(img0);
            var div1 = document.createElement("div");
            div1.className = "infor";
            div0.appendChild(div1);
            var p1 = document.createElement("p");
            div1.appendChild(p1);
            var span1 = document.createElement("span");
            span1.className = "color";
            p1.appendChild(span1);
            span1.textContent = data.shop_data[i].shop_name;
            var span2 = document.createElement("span");
            span2.textContent = "店铺等级";
            span2.style.marginLeft = "10px";
            p1.appendChild(span2);
            var br1 = document.createElement("br");
            div1.appendChild(br1);
            var br2 = document.createElement("br");
            div1.appendChild(br2);
            var p2 = document.createElement("p");
            p2.textContent = data.shop_data[i].shop_desc;
            div1.appendChild(p2);
            var span3 = document.createElement("span");
            span3.className = "inshop";
            span3.textContent = "进入店铺";
            div1.appendChild(span3);
            var br3 = document.createElement("br");
            div1.appendChild(br3);
            var br4 = document.createElement("br");
            div1.appendChild(br4);
            var p3 = document.createElement("p");
            p3.textContent = data.shop_data[i].addr;
            div1.appendChild(p3);
            var span4 = document.createElement("span");
            span4.className = "shu";
            span4.textContent = "人气：" + data.shop_data[i].shop_visit + "次浏览";
            div1.appendChild(span4);
            /*店铺好评榜*/
            var one = document.createElement("div");
            one.className = "one";
            good.appendChild(one);
            var number = document.createElement("div");
            number.className = "number";
            number.innerHTML = "1";
            one.appendChild(number);
            var img1 = document.createElement("img");
            img1.src = data.shop_data[i].shop_ico;
            one.appendChild(img1);
            var xinxi = document.createElement("div");
            xinxi.className = "xinxi";
            one.appendChild(xinxi);
            var rightP1 = document.createElement("p");
            xinxi.appendChild(rightP1);
            var rightS = document.createElement("span");
            rightS.textContent = data.shop_data[i].shop_name;
            rightP1.appendChild(rightS);
            var br6 = document.createElement("br");
            xinxi.appendChild(br6);
            var br7 = document.createElement("br");
            xinxi.appendChild(br7);
            var rightP2 = document.createElement("p");
            rightP2.textContent = data.shop_data[i].comments + "条评论";
            xinxi.appendChild(rightP2);
        }
    }

var divlist=document.querySelectorAll(".shop");
var inshop=document.querySelector(".inshop");
function blockHandler(e) {
    alert(1)
   // $(".inshop").css("display","none")
}

